home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 35 / Amiga Format AFCD35 (Issue 119, Jan 1999).iso / -in_the_mag- / reader_requests / fredobbutils / bbsrc / memchk20.s < prev    next >
Text File  |  1998-11-06  |  6KB  |  351 lines

  1. *** Bootblock Spécial:    MEMCHK    2.0
  2. * Coded by Frédéric Bassaler '95
  3.  
  4. * Version 2.0: utilise une interface intuition.
  5. * (uses an Intuition screen rather than a non-system display)
  6.  
  7. *** Au moment du boot:
  8. * bouton DROIT de la souris  =>    MemChk
  9. *    - examine les vecteurs d'execbase
  10. *    - visualisation de la mémoire
  11. * --> permet donc de détecter la présence d'un virus ou autre code résident
  12.  
  13. * Si les vecteurs de Reset ne sont pas à 0 au moment du boot,
  14. * alors MemChk apparait
  15.  
  16. * FOR THE ENGLISH-SPEAKING:
  17. *    This bootblock is some kind of 'Memory Check & Display' bootblock
  18. *    It will only tell if a resident program is found in memory
  19. *    and then you'll be able to check by yourself...
  20. *
  21. *    I used it on my system (write-protected) disk so it could tell
  22. *    if a virus (or any other resident module) was in memory at boot time 
  23. *
  24. * HOLD RIGHT-MOUSE during boot to enter the program
  25.  
  26.     incdir    asm:/Include/
  27.     include    equ.s
  28.     include    exec/types.i
  29.     include    graphics/text.i
  30.     include    graphics/gfx.i
  31.     include    graphics/rastport.i
  32.  
  33.     rsreset
  34. intbase    rs.l    1
  35. Scr    rs.l    1
  36. rast    rs.l    1
  37. XStart    rs.w    1
  38. YStart    rs.w    1
  39. diskio    rs.l    1
  40. Offset    rs.l    1
  41. Vectors    rs.l    12
  42. TextPtr    rs.b    2000
  43. VARSIZE    rs.w    0
  44.  
  45. DMPYStart=52
  46. NCHR=70
  47. NLINES=26
  48. DMPSIZE=NCHR*NLINES
  49.  
  50. DBUG=0        ;put 0 instead of 1 to disable DEBUG MODE
  51.  
  52. Start:
  53.     IFEQ    DBUG
  54.     dc.b    "DOS",0
  55.     dc.l    0
  56.     dc.l    $370
  57.     ENDC
  58.  
  59.     IFEQ    DBUG
  60.     tst.l    46(a6)
  61.     bne.b    MemChk
  62.     tst.l    550(a6)
  63.     bne.b    MemChk
  64.     btst    #10,$dff016
  65.     bne.w    Init
  66.     ENDC
  67. MemChk
  68.     movem.l    d0-a6,-(sp)
  69.     lea    -VARSIZE(sp),sp    ;on utilise la pile comme base des variables
  70.     move.l    sp,a5        ;VarBase en a5
  71.  
  72. * éteindre moteur
  73. ;    IFEQ    DBUG
  74. ;    move.l    a1,DiskIo(a5)
  75. ;    bsr.w    MotorOff
  76. ;    ENDC
  77.  
  78.     IFNE    DBUG
  79.     move.l    4.w,a6
  80.     ENDC
  81. *** Mettre en place le contexte graphique (set up screen)
  82.     move.l    4.w,a6
  83.     move.l    $9c(a6),d6        ;gfxbase
  84.  
  85.     lea    intname(pc),a1
  86.     jsr    -408(a6)
  87.     move.l    d0,intbase(a5)
  88.     move.l    d0,a6
  89.     lea    New.Screen(pc),a0
  90.     jsr    OpenScreen(a6)
  91.     move.l    d0,Scr(a5)
  92.     move.l    d0,a0
  93.     lea    84(a0),a0
  94.     move.l    a0,rast(a5)
  95.  
  96.     move.l    d6,a6
  97.  
  98.     lea    topaz8(pc),a0
  99.     move.l    154(a6),a1
  100.     move.l    10(a1),(a0)    ;ln_name: topaz.font
  101.     jsr    OpenFont(a6)
  102.     move.l    d0,a0
  103.     move.l    d0,-(sp)
  104.     move.l    rast(a5),a1
  105.     jsr    SetFont(a6)
  106.     move.l    (sp)+,a1
  107.     jsr    CloseFont(a6)
  108.  
  109.     moveq    #10,d0
  110.     moveq    #10,d1
  111.     movem    d0-d1,XStart(a5)
  112.     lea    main.txt(pc),a0
  113.     bsr.w    print
  114. ********************************************************
  115.     move.l    4.w,a6
  116.     lea    Vectors(a5),a0
  117.     move.l    a0,a1
  118.     move.l    a0,a3
  119.     lea    42(a6),a2
  120.     REPT    3
  121.     move.l    (a2)+,(a0)+
  122.     ENDR
  123.  
  124.     lea    546(a6),a2
  125.     REPT    3
  126.     move.l    (a2)+,(a0)+
  127.     ENDR
  128.     move.l    144(a6),(a0)+    ;IntVector: VertBlank Interrupt
  129.     moveq    #-1,d0        ;-1=fin
  130.     move.l    d0,(a0)
  131.     lea    vector.txt(pc),a0
  132.     bsr.w    RawPrint
  133.  
  134. *** AsciiDump de la mémoire 'occupée' par le code résident
  135.     move.l    46(a6),d0    ;coolcapture: pointeur sur prg résident
  136.     bne.b    .dmp
  137.     move.l    550(a6),d0    ;kicktagptr
  138.     bne.b    .dmp
  139.     moveq    #0,d0
  140. .dmp    move.l    d0,a0
  141. dmp
  142.     bsr.w    MemDmp
  143. MainLoop:
  144. .z
  145.     move.l    Offset(a5),a0
  146.     move.b    $bfec01,d0
  147.     ror.b    #1,d0
  148.     not.b    d0        ;code rawkey
  149. ;    cmp.b    #$17,d0        ;I
  150. ;    bne.b    .z1
  151. ;    bsr.w    Install
  152. ;    bra.b    .z
  153. .z1    btst    #6,$bfe001
  154.     beq.b    CloseAll
  155. ;    cmp.b    #$40,d0
  156. ;    beq.b    .next_vec
  157.     cmp.b    #$45,d0        ;Esc
  158.     beq.b    Reset
  159.     cmp.b    #$4d,d0
  160.     beq.b    .more
  161.     cmp.b    #$4c,d0
  162.     bne.b    .z
  163. .less
  164.     sub    #DMPSIZE,a0
  165.     bra.b    dmp
  166. .more
  167.     add    #DMPSIZE,a0
  168.     bra.b    dmp
  169. ;.next_vec
  170. ;    move.l    (a3)+,d0
  171. ;    moveq    #-1,d1
  172. ;    cmp.l    d0,d1
  173. ;    bne.b    .nxt
  174. ;    lea    Vectors(a5),a3
  175. ;    bra.b    .z
  176. ;.nxt    move.l    d0,a0
  177. ;    bra.b    dmp
  178. *** Effacer les vecteurs de reset & rebooter
  179. Reset:
  180.     clr.l    46(a6)        ;coolcapture
  181.     clr.l    546(a6)        ;kickmemptr
  182.     clr.l    550(a6)        ;kicktagptr
  183.     clr.l    554(a6)        ;kickchecksum
  184. Reset2
  185.     IFNE    DBUG
  186.     bra.b    CloseAll
  187.     ENDC
  188.  
  189. ;do a system reset (this is a dirty method!)
  190.     move.l    #$f80000,$80.w
  191.     trap    #0
  192. ; You should use ColdReboot() under 2.0+ systems
  193.  
  194. *** libérer tout
  195. CloseAll:
  196.     move.l    Scr(a5),a0
  197.     move.l    intbase(a5),a6
  198.     jsr    CloseScreen(a6)
  199.     move.l    a6,a1
  200.     move.l    4.w,a6
  201.     jsr    CloseLibrary(a6)
  202. fin
  203.     lea    VARSIZE(sp),sp    ;restitue la pile
  204.     movem.l    (sp)+,d0-a6
  205. Init
  206.     IFEQ    DBUG
  207.     move    #$f00,$dff180    ;écran rouge pour avertir
  208.     lea    dosname(pc),a1
  209.     jsr    -96(a6)
  210.     move.l    d0,a0
  211.     move.l    22(a0),a0
  212.     ENDC
  213.     moveq    #0,d0
  214.     rts
  215.  
  216. PutChr    move.b    d0,(a3)+
  217.     rts
  218. *** Formatage & sortie de texte
  219. * <-- a0: format a1: data
  220. RawPrint:
  221.     lea    PutChr(pc),a2
  222.     lea    TextPtr(a5),a3
  223.     move.l    a3,-(sp)
  224.     move.l    4.w,a6
  225.     jsr    -522(a6)
  226.     move.l    (sp)+,a0
  227. *** Sortir du texte
  228. * <-- a0: adr texte (terminé par 0)
  229. print
  230.     movem.l    d0-a6,-(sp)
  231.     movem    XStart(a5),d0-d1
  232.     move.l    d6,a6
  233.     move.l    rast(a5),a3
  234. readchr
  235.     move.b    (a0)+,d7
  236.     beq.b    printend
  237.     cmp.b    #$a,d7            linefeed
  238.     beq.b    lf
  239.     bsr.b    prnt
  240.     addq    #8,d0
  241.     bra.b    readchr
  242. lf
  243.     addq    #8,d1
  244.     move    XStart(a5),d0
  245.     bsr.b    Mov
  246.     bra.b    readchr
  247. prnt
  248.     bsr.b    Mov
  249.     movem.l    a0/d0/d1,-(sp)
  250.     subq.l    #1,a0
  251.     moveq    #1,d0
  252. Txt    move.l    a3,a1
  253.     jsr    Text(a6)
  254.     bra.b    movf
  255. Mov
  256.     movem.l    a0/d0/d1,-(sp)
  257.     move.l    a3,a1
  258.     jsr    Move(a6)
  259. movf    movem.l    (sp)+,a0/d0/d1
  260.     rts
  261. printend
  262.     movem    d0-d1,XStart(a5)
  263.     movem.l    (sp)+,d0-a6
  264.     rts
  265.  
  266. *** MemDump Ascii
  267. * <-- a0: adresse de début
  268. MemDmp:
  269.     movem.l    d0-a6,-(sp)
  270.     move.l    a0,Offset(a5)
  271. .pr
  272.     move.l    rast(a5),a3
  273.     moveq    #0,d0
  274.     moveq    #DMPYStart,d1
  275.     move.l    d6,a6
  276.     bsr.b    Mov
  277.  
  278.     move.l    a0,a4
  279.     moveq    #NLINES-1,d5
  280. .prlop
  281.     moveq    #9,d4
  282.     move.l    (a5),a1
  283.     lea    TextPtr(a1),a1
  284.     move.l    a1,-(sp)
  285.     move.l    a0,d7
  286.     bsr.b    Long2Hex
  287.     move.b    #$20,(a1)+
  288.     move.l    (sp)+,a1
  289.     move.l    a0,a4
  290.     move.l    a1,a0
  291.     bsr.b    .txt
  292.     move.l    a4,a0
  293.     moveq    #NCHR,d4
  294.     bsr.b    .txt
  295.     add.l    d4,a0
  296.     moveq    #0,d0
  297.     addq    #8,d1
  298.     bsr.b    Mov
  299.     dbf    d5,.prlop
  300.  
  301.     movem.l    (sp)+,d0-a6
  302.     rts
  303. .txt
  304.     movem.l    d0/d1/a0,-(sp)
  305.     move.l    d4,d0
  306.     bra.b    Txt
  307.  
  308. *** Hex --> HexString
  309. * <-- d7: long, a1: outputstr
  310. Long2Hex:
  311.     movem.l    d0-d2/a0,-(sp)
  312.     moveq    #7,d2
  313. .bcl    rol.l    #4,d7
  314.     move    d7,d1
  315.     and.b    #$0f,d1
  316.     add.b    #$30,d1
  317.     cmp.b    #$3a,d1
  318.     bcs.b    .ok
  319.     addq.b    #7,d1
  320. .ok    move.b    d1,(a1)+
  321.     dbf    d2,.bcl
  322.     movem.l    (sp)+,d0-d2/a0
  323.     rts
  324.  
  325. *** DATA
  326. New.Screen:
  327.     dc.w    0,0,640,-1,1,-1,$8000,$101
  328.     dc.l    0,0,0,0
  329.  
  330. topaz8    dc.l    0
  331.     dc.w    8
  332.     dc.b    0,0
  333.  
  334. intname    dc.b "intuition.library",0
  335. dosname    dc.b "dos.library",0
  336.  
  337. main.txt
  338.  DC.B "MemChk 2.0 © F. Bassaler * "
  339.  dc.b "LMB=Exit\ESC=ClrMem\Up,Down",$a,$a
  340.  dc.b 0
  341. vector.txt
  342.  dc.b "Cold    %lx Cool %lx Warm %lx",$a
  343.  dc.b "KickMem %lx Tag  %lx Chk  %lx",$a
  344.  dc.b "VBL %lx"
  345.  dc.b 0
  346.  
  347.  dc.b "WHEN BOOTING,HOLD <RMB> TO ENTER MEMCHK"
  348.  
  349. End:
  350.     dcb.b    512*2,0
  351.